package com.roncoo.education.api;

import cn.hutool.json.JSONUtil;
import com.roncoo.education.api.request.RegistrationRequest;
import com.roncoo.education.db.service.RegistrationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;

@RestController
@RequestMapping("/api")
@CrossOrigin(origins = "*", allowedHeaders = "*")
public class RegistrationController {

    @Resource
    private RegistrationService registrationService;

    @PostMapping("/saveRegistration")
    public String saveProduct(@Valid @RequestBody RegistrationRequest req, HttpServletRequest request){
        Map<String,String> ret= registrationService.saveRegistra(req);
        return JSONUtil.toJsonStr(ret);
    }

}
